package SwingView;

import javax.swing.*;

import java.awt.*;

public class CmsAccountPanel extends JPanel {

	final private JComboBox<String> jcbCourseList;
	final private JLabel jlUserType;
	final private JLabel jlUserName;
	final private JbtLogoutButton jbtLogout;
	final private JbtHomeButton jbtHome;
	final private JButton jbtCourse;
	
	final static private int IPADY = 16;
	
	public CmsAccountPanel(){
		
		//Instantiate the components
		jcbCourseList = new JComboBox();
		jlUserType = new JLabel("");
		jlUserName = new JLabel("");
		jbtLogout = new JbtLogoutButton();
		jbtHome = new JbtHomeButton();
		jbtCourse = new JButton("Course");
		
		//Set up MAIN ACCOUNT PANEL:
		setLayout(new GridBagLayout());
		setOpaque(false);
		
		//setup and add the Course List Combo Box:
		jcbCourseList.setPreferredSize(new Dimension(300,22));
		jcbCourseList.setBorder(BorderFactory.createEmptyBorder(0, 6, 0, 0));
		GridBagConstraints cCL = new GridBagConstraints();
		cCL.gridx = 0;
		cCL.ipadx = 16;
		cCL.ipady = IPADY;
		cCL.anchor = GridBagConstraints.LINE_START;
		add(jcbCourseList,cCL);
		
		//add the home button
		GridBagConstraints cH = new GridBagConstraints();
		cH.gridx = 1;
		cH.ipadx = 8;
		cH.ipady = IPADY;
		cH.anchor = GridBagConstraints.LINE_START;
		add(jbtHome,cH);
		
		
		//set up and add the user type label
		jlUserType.setForeground(Color.WHITE);
		GridBagConstraints cUT = new GridBagConstraints();
		//cUT.gridx = 2;
		cUT.ipady = IPADY;
		cUT.anchor = GridBagConstraints.LINE_END;
		cUT.weightx = 1.0;
		add(jlUserType,cUT);
		
		//Set up and add the user full name label
		jlUserName.setForeground(Color.WHITE);
		jlUserName.setMaximumSize(new Dimension(50,22));
		GridBagConstraints cUN = new GridBagConstraints();
		cUN.gridx = 3;
		cUN.anchor = GridBagConstraints.LINE_START;
		cUN.ipadx = 5;
		cUN.ipady = IPADY;
		add(jlUserName,cUN);
		
		//add log out button
		GridBagConstraints cLO = new GridBagConstraints();
		cLO.gridx = 4;
		cLO.anchor = GridBagConstraints.LINE_END;
		cLO.ipadx = 16;
		cLO.ipady = IPADY;
		add(jbtLogout,cLO);
		
	}
	
	//---------------------------------------------------------
	//BUTTON CLASSES:
	//---------------------------------------------------------	
	public class JbtLogoutButton extends JButton{
		
		public JbtLogoutButton(){
			setIcon(new ImageIcon("./assets/btnLogout.png"));
			setRolloverIcon(new ImageIcon("./assets/btnLogout_RO.png"));
			setBorder(BorderFactory.createEmptyBorder());
		}
	}
	
	public class JbtHomeButton extends JButton{
		public JbtHomeButton(){
			setIcon(new ImageIcon("./assets/btnHome.png"));
			setRolloverIcon(new ImageIcon("./assets/btnHome_RO.png"));
			setBorder(BorderFactory.createEmptyBorder());
		}
	}

	//---------------------------------------------------------
	//GETTERS:
	//---------------------------------------------------------
	public JComboBox<String> getJcbCourseList() {
		return jcbCourseList;
	}

	public JLabel getJlUserType() {
		return jlUserType;
	}

	public JLabel getJlUserName() {
		return jlUserName;
	}

	public JbtLogoutButton getJbtLogout() {
		return jbtLogout;
	}
	
	public JButton getJbtCourse(){
		return this.jbtCourse;
	}
	
	public JButton getJbtHome(){
		return this.jbtHome;
	}
}
